package com.api;

import lombok.Builder;
import lombok.Data;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * $Message
 * Created with IDEA
 * Author: LuoHengYi
 * Date: 2022/6/14
 * Time: 14:49
 */
@Data
@Builder
public class Message   implements Serializable {


    private static final long serialVersionUID = 1611808620613062062L;


    /**
     * 消息唯一id
     */
    private String messageId;


    /* 消息的主题：可理解为消息的key，用于匹配某条消息的生产者和消费者 */
    /* 交换机的名称 */
    private String topic;

    /* 消息的路由规则，exchange 根据 routingKey 发送到那个queue*/
    private String routingKey = "";

    /* 消息携带的属性 */
    private Map<String, Object> attributes = new HashMap<>();

    /* 消息延迟的配置 */
    private int delayMills;

    /*消息类型 默认为可靠性消息*/
    private String messageType = MessageType.CONFIRM;


    public Message() {

    }

    public Message(String messageId, String topic, String routingKey, Map<String, Object> attributes, int delayMills, String messageType) {
        this.messageId = messageId;
        this.topic = topic;
        this.routingKey = routingKey;
        this.attributes = attributes;
        this.delayMills = delayMills;
        this.messageType = messageType;
    }
}
